<include file="Public:head" />
<link href="__APP__/Application/{$Think.MODULE_NAME}/Public/css/home.css" rel="stylesheet" type="text/css" />
<link href="__APP__/Application/{$Think.MODULE_NAME}/Public/css/order.css" rel="stylesheet" type="text/css" />
<script  type="text/javascript">
function editAddr(obj,id){
        var addr = obj.parent("td").prevAll('.addr').text();
         var truename = obj.parent("td").prevAll('.truename').text();      
        var phone = obj.parent("td").prevAll('.phone').text();
        var phone2 = obj.parent("td").prevAll('.phone2').text();
        $.post("{:U('Box/addAddr')}",{
            id:id,
            phone:phone,
            phone2:phone2,
            addr:addr,
            truename:truename,
            mtype:'home'
        },function(data){
            $('#mainbox').html(data);
            showbgbox('#browsebox',0,0);
        })
       
    }
    function addAddr(){
        $.post("{:U('Box/addAddr')}",{mtype:'home'
        },function(data){
            $('#mainbox').html(data);
            showbgbox('#browsebox',0,0);
        })
    }
    function delAddr(obj,id){
        $.post("{:U('Box/delAddr')}",{
            id:id
        },function(data){
            obj.parents("tr").remove();
            closebgbox3('#mainbox2');
        })
    }
    function setAddr(obj,id){
    $(".order_p_address").removeClass("order_p").addClass("order_p2");
            obj.parent(".order_p_address").removeClass("order_p2").addClass("order_p");
        $.post("{:U('Box/setAddr')}",{
            id:id
        },function(data){
            $(".default").hide();
            $('.to_default').show();
            obj.next('.default').show();
            obj.next('.to_default').hide();
            obj.hide();
        })
    }
    </script>
<div id="wrap">
     <div id="school">{$type=0|getAreaName}
            <a href="__APP__/?type=clean">[切换位置]</a>
            <span>/</span>
            <em>地址管理</em>
        </div>
        <div id="container" class="clearfix">
            <!--end of navigation-->
            <div class="shadow clearfix" id="pCenter">
      <include file="Public:left" />

                <div id="pAccount">
                    <div id="historyInfo" class="acc_con">
                        <p class="ac_title">个人信息 
                            <a  onclick="addAddr()"style="cursor:pointer;float:right;display: inline-block;color:#55AADD;font-size: 12px;font-weight: normal;margin-right:8px;">新增管理地址</a></p>
                        <div class="ac_content">
                            <table width="100%">
                                <thead>
                                    <tr>
                                        <td>姓名</td>
                                        <td class="td_center">联系电话</td>
                                        <td class="td_center">备选电话</td>
                                        <td>详细地址</td>
                                        <td>操作</td>
                                    </tr>
                                </thead>
                                <tbody id="tbDeliveryInfo">
                                        <foreach name="lists" item="row">
                                            <tr id="tr_{$row.id}">
                                                <td class="truename" width="90px">{$row.truename}</td>
                                                 <td class="phone" width="90px">{$row.phone}</td>
                                                <td class="phone2" width="90px">{$row.phone2}</td>
                                                <td class="addr">{$row.addr}</td>
                                                <td width="145px">
                                                    
                                                    <a href="javascript:;" class="to_default" onclick="setAddr($(this),'{$row.id}')" <if condition="$row.is_default eq 1">style='display:none'</if>>设为默认</a>
                                              
                                                    <a class="default" href="javascript:;" <if condition="$row.is_default eq 0">style='display:none'</if>>默认信息</a>
                                                   
                                                    <a href="javascript:;" class="change" onclick="editAddr($(this),'{$row.id}')">修改</a> 
                                                        <a href="javascript:;" id="del_{$row.id}" class="del" data-func="delAddr($('#del_{$row.id}'),{$row.id})" onclick="confirmBox($(this),'确定要删除该地址吗')">删除</a>
                                                </td>
                                            </tr>
                                            </foreach>
                                        
                                </tbody>
                            </table>
                        </div>
                    </div>
                   
                </div>
            </div>
            <!--end of p_content-->
        </div>
   <include file="Public:foot" />